package gui.calendarview;

import java.awt.Color;
import java.awt.Component;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import no.ntnu.fp.model.ActivityType;

public class DayListCellRenderer extends JLabel implements ListCellRenderer {

	private static final long serialVersionUID = 1L;

	public DayListCellRenderer() {}
	
	public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
		setText(value.toString());
		setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
		if (isSelected) {
			setBackground(list.getSelectionBackground());
			setForeground(list.getSelectionForeground());
		} else {
			ListElement e = (ListElement) value;
			if ( e.getModel() != null )
				if ( e.getModel().getType() == ActivityType.MEETING )
					setBackground(Color.YELLOW);
				else
					setBackground(Color.BLUE);
			else
				setBackground(Color.WHITE);
			setForeground(Color.BLACK);
		}
		setEnabled(list.isEnabled());
		setFont(list.getFont());
		setOpaque(true);
		return this;
	}

}
